<template>
<div>
  <div class="look animated fadeInUp" >
    <img class="title" src="../assets/img/title.png">
    <div class="message">
      <img v-if="imgUrl" :src="imgUrl">
    </div>
    <div class="addr">
      <span class="from">from</span>
      <span class="avatar">
        <img :src="userImg">
      </span>
      <span>{{name}}</span>
    </div>
    <div class="an">长按图片保存图片到本地</div>
  </div>
</div>
</template>

<script>
import coding from '../assets/js/coding.js'
export default {
  name: 'Success',
  data () {
    return {
      imgUrl: '',
      showMask: false,
      name: '',
      userImg: ''
    }
  },
  mounted () {
    let bbid = sessionStorage.getItem('bbid')
    let objData = {
      userId: sessionStorage.getItem('userId'),
      confessionId: bbid
    }
    this.axios({
      method: 'get',
      url: 'http://211.149.169.49:8080/confession/user/getUserById.do',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      },
      data: objData,
      params: objData
    }).then(res => {
      // 对图像进行解码
      var base = new coding.Base64()
      let decodeCanvasImgUrlEd = base.decode(res.data.data.confessionImg)
      this.imgUrl = decodeCanvasImgUrlEd
      this.userImg = res.data.data.userImg || 'http://www.qq22.com.cn/uploads/allimg/c170101/14S24020O0430-133M2.jpg'
      this.name = res.data.data.userName
    })
  },
  methods: {
    onShowMask () {
      this.showMask = !this.showMask
    }
  }
}
</script>
<style  @scoped lang="less">
    .look{
      text-align: center;
      width: 100%;
      .title{
        width: 4.5rem;
        margin: 0 auto;
        padding-top: 1rem;
        padding-bottom: .6rem;
        height: 1.2rem;
      }
      .message{
        width: 5rem;
        background: url(../assets/img/message.png);
        background-size: 100% 100%;
        height: 5rem;
        margin: 0 auto;
        padding: 1.4rem .3rem .3rem .3rem;
      }
      .addr{
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: 5rem;
        margin: 0 auto;
        font-size: .2rem;
        .from{
          display: inline-block;
          margin-right: .2rem;
        }
        .avatar{
          display: inline-block;
          width: .95rem;
          margin-right: .2rem;
          height: .95rem;
          border-radius: .91rem;
          border: .01rem solid #DA3615;
          padding: .05rem;
          img{
            width: .95rem;
            height: .95rem;
            border-radius: .95rem;
          }
        }
      }
    }
    .an{
      font-size: .2rem;
      color: #000;
      margin-top: .3rem;
      color: #1f0404;
    }
    </style>
